﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class FireEffect : BaseMono
{
	public Image Image;
	public override void onAwake()
	{
		if (!Image)
		{
			Image = GetComponent<Image>();
		}
	}

	public void Fire()
	{
		StartCoroutine(HideExplodeEffect(0.3f));
	}

	IEnumerator HideExplodeEffect(float time) {
		yield return new WaitForSeconds(time);

		float alpha = 1;
		while (alpha > 0) {
			Image.color = new Color(1, 1, 1, alpha);

			alpha -= 0.16f;
			alpha = Mathf.Max(0, alpha);
			yield return null;
		}

		Destroy(gameObject);
	}
}
